window.onload = function () {
    class Login {
        constructor() {
            this.phone = $('#phone');
            this.phone2 = $('#phone2')
            this.phone4 = $('#phone4')
            this.arr = [false,false,false];
            this.addEvent()
        }
        addEvent() {
            let that = this;
            this.phone.blur(function () {
                let re = /^1[0-9]{10}$/;
                let val = this.value;
                // console.log(val);
                if(re.test(val)) {
                    $('.phone1').text('格式输入正确');
                    that.arr[0] = true;
                }else{
                    $('.phone1').text('格式输入错误请重新输入');
                    that.arr[0] = false;
                }   
            })
            this.phone2.blur(function (){
                let re = /^\w{6,20}$/;
                let ps = this.value;
                if(re.test(ps)) {
                    $('.phone3').text('格式输入正确');
                    that.arr[1] = true;
                }else{
                    $('.phone3').text('格式输入错误请重新输入6-20个字符');
                    that.arr[1] = false;
                }   
            })
            this.phone4.blur(function(){
                let re = that.phone2.value;
                let sure = that.value;
                if(sure == re){
                    $('.phone5').text('格式输入正确');
                    that.arr[2] = true;
                }else{
                    $('.phone5').text('密码与上次不符请重新输入');
                    that.arr[2] = false;
                }
            })
        }
    }
    new Login()
}